<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"lianyouli.gitee.io","root":"/","scheme":"Mist","version":"7.8.0","exturl":false,"sidebar":{"position":"right","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="Nifi 采集Mysql的binlog示例">
<meta property="og:type" content="article">
<meta property="og:title" content="Nifi Mysql CDC">
<meta property="og:url" content="https://lianyouli.gitee.io/IT/it-bigdata-nifi-mysql-cdc/index.html">
<meta property="og:site_name" content="联友的Blog">
<meta property="og:description" content="Nifi 采集Mysql的binlog示例">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://lianyouli.gitee.io/IT/it-bigdata-nifi-mysql-cdc/image-20220403104549750.png">
<meta property="og:image" content="https://lianyouli.gitee.io/IT/it-bigdata-nifi-mysql-cdc/image-20220403104650480.png">
<meta property="og:image" content="https://lianyouli.gitee.io/IT/it-bigdata-nifi-mysql-cdc/image-20220403105008677.png">
<meta property="og:image" content="https://lianyouli.gitee.io/IT/it-bigdata-nifi-mysql-cdc/image-20220403110758271.png">
<meta property="og:image" content="https://lianyouli.gitee.io/IT/it-bigdata-nifi-mysql-cdc/image-20220403111957998.png">
<meta property="og:image" content="https://lianyouli.gitee.io/IT/it-bigdata-nifi-mysql-cdc/image-20220403112736423.png">
<meta property="og:image" content="https://lianyouli.gitee.io/IT/it-bigdata-nifi-mysql-cdc/image-20220403113013282.png">
<meta property="og:image" content="https://lianyouli.gitee.io/IT/it-bigdata-nifi-mysql-cdc/image-20220403165001672.png">
<meta property="og:image" content="https://lianyouli.gitee.io/IT/it-bigdata-nifi-mysql-cdc/image-20220403165038376.png">
<meta property="og:image" content="https://lianyouli.gitee.io/IT/it-bigdata-nifi-mysql-cdc/image-20220403164622602.png">
<meta property="og:image" content="https://lianyouli.gitee.io/IT/it-bigdata-nifi-mysql-cdc/image-20220403161544824.png">
<meta property="og:image" content="https://lianyouli.gitee.io/IT/it-bigdata-nifi-mysql-cdc/image-20220403113226934.png">
<meta property="og:image" content="https://lianyouli.gitee.io/IT/it-bigdata-nifi-mysql-cdc/image-20220403113606962.png">
<meta property="og:image" content="https://lianyouli.gitee.io/IT/it-bigdata-nifi-mysql-cdc/image-20220403113827340.png">
<meta property="og:image" content="https://lianyouli.gitee.io/IT/it-bigdata-nifi-mysql-cdc/image-20220403161727165.png">
<meta property="article:published_time" content="2022-04-03T02:33:18.000Z">
<meta property="article:modified_time" content="2022-04-25T01:23:44.447Z">
<meta property="article:author" content="李联友">
<meta property="article:tag" content="bigdata">
<meta property="article:tag" content="dataflow">
<meta property="article:tag" content="nifi">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://lianyouli.gitee.io/IT/it-bigdata-nifi-mysql-cdc/image-20220403104549750.png">

<link rel="canonical" href="https://lianyouli.gitee.io/IT/it-bigdata-nifi-mysql-cdc/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>Nifi Mysql CDC | 联友的Blog</title>
  


  <script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?eb9f10e46b1f09801805fc668f13d477";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="联友的Blog" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">联友的Blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">密涅瓦的猫头鹰在黄昏起飞</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签<span class="badge">25</span></a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类<span class="badge">8</span></a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档<span class="badge">31</span></a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://lianyouli.gitee.io/IT/it-bigdata-nifi-mysql-cdc/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/header.jpg">
      <meta itemprop="name" content="李联友">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="联友的Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Nifi Mysql CDC
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2022-04-03 10:33:18" itemprop="dateCreated datePublished" datetime="2022-04-03T10:33:18+08:00">2022-04-03</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2022-04-25 09:23:44" itemprop="dateModified" datetime="2022-04-25T09:23:44+08:00">2022-04-25</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/IT/" itemprop="url" rel="index"><span itemprop="name">IT</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <blockquote>
<p>Nifi 采集Mysql的binlog示例</p>
</blockquote>
<a id="more"></a>

<h2 id="环境"><a href="#环境" class="headerlink" title="环境"></a>环境</h2><ul>
<li><p>MySQL 8.0.28</p>
</li>
<li><p>Nifi 1.15.3</p>
</li>
</ul>
<h2 id="检查MySQL-binlog开启情况"><a href="#检查MySQL-binlog开启情况" class="headerlink" title="检查MySQL binlog开启情况"></a>检查MySQL binlog开启情况</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">show variables like '%log_bin%';</span><br></pre></td></tr></table></figure>

 <img src="/IT/it-bigdata-nifi-mysql-cdc/image-20220403104549750.png" alt="image-20220403104549750" style="zoom:50%;">

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#</span><span class="bash"> 我这里的global transaction id 模式是关闭的</span></span><br><span class="line">show variables like '%gtid%';</span><br></pre></td></tr></table></figure>

 <img src="/IT/it-bigdata-nifi-mysql-cdc/image-20220403104650480.png" alt="image-20220403104650480" style="zoom:50%;">

<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">show variables like 'server_id';</span><br></pre></td></tr></table></figure>

 <img src="/IT/it-bigdata-nifi-mysql-cdc/image-20220403105008677.png" alt="image-20220403105008677" style="zoom:50%;">

<h2 id="创建MySQL用户和数据库"><a href="#创建MySQL用户和数据库" class="headerlink" title="创建MySQL用户和数据库"></a>创建MySQL用户和数据库</h2><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">CREATE</span> <span class="keyword">USER</span> nifi@<span class="string">'%'</span> <span class="keyword">IDENTIFIED</span> <span class="keyword">WITH</span> mysql_native_password <span class="keyword">BY</span> <span class="string">'SecretPasswd'</span>;</span><br><span class="line"><span class="keyword">CREATE</span> <span class="keyword">DATABASE</span> tests;</span><br><span class="line"><span class="keyword">GRANT</span> <span class="keyword">select</span>, <span class="keyword">show</span> <span class="keyword">databases</span>  <span class="keyword">ON</span> *.* <span class="keyword">to</span> nifi@<span class="string">'%'</span>;</span><br><span class="line"><span class="keyword">GRANT</span> <span class="keyword">ALL</span> <span class="keyword">PRIVILEGES</span> <span class="keyword">ON</span> tests.* <span class="keyword">to</span> nifi@<span class="string">'%'</span>;</span><br><span class="line"><span class="keyword">GRANT</span> <span class="keyword">REPLICATION</span> <span class="keyword">SLAVE</span> <span class="keyword">ON</span> *.* <span class="keyword">to</span> nifi@<span class="string">'%'</span>;</span><br><span class="line"><span class="keyword">GRANT</span> <span class="keyword">REPLICATION</span> <span class="keyword">CLIENT</span> <span class="keyword">ON</span> *.* <span class="keyword">to</span> nifi@<span class="string">'%'</span>;</span><br></pre></td></tr></table></figure>

<h2 id="配置DistributedMapCacheServer-amp-Client"><a href="#配置DistributedMapCacheServer-amp-Client" class="headerlink" title="配置DistributedMapCacheServer&amp;Client"></a>配置DistributedMapCacheServer&amp;Client</h2><ul>
<li><p>DistributedMapCacheServer</p>
<blockquote>
<p>global menu  –&gt; Controller Settings –&gt; REPORTING TASK CONTROLLER SERVICES</p>
</blockquote>
 <img src="/IT/it-bigdata-nifi-mysql-cdc/image-20220403110758271.png" alt="image-20220403110758271" style="zoom:50%;">

<p><img src="/IT/it-bigdata-nifi-mysql-cdc/image-20220403111957998.png" alt="image-20220403111957998"></p>
<blockquote>
<p>这里选择最简单的DistributedMapCacheServer。</p>
</blockquote>
 <img src="/IT/it-bigdata-nifi-mysql-cdc/image-20220403112736423.png" alt="image-20220403112736423" style="zoom:30%;">


</li>
</ul>
  <img src="/IT/it-bigdata-nifi-mysql-cdc/image-20220403113013282.png" alt="image-20220403113013282" style="zoom:30%;">

<ul>
<li><p>DistributedMapCacheClient</p>
<blockquote>
<p>可以采用这种方式创建，也可以在CaptureChangeMySQL组件里选择创建一个服务。</p>
</blockquote>
 <img src="/IT/it-bigdata-nifi-mysql-cdc/image-20220403165001672.png" alt="image-20220403165001672" style="zoom:50%;">
 <img src="/IT/it-bigdata-nifi-mysql-cdc/image-20220403165038376.png" alt="image-20220403165038376" style="zoom:50%;">

<img src="/IT/it-bigdata-nifi-mysql-cdc/image-20220403164622602.png" alt="image-20220403164622602" style="zoom:30%;">

</li>
</ul>
<h2 id="创建和配置CaptureChangeMySQL"><a href="#创建和配置CaptureChangeMySQL" class="headerlink" title="创建和配置CaptureChangeMySQL"></a>创建和配置CaptureChangeMySQL</h2><ul>
<li><p>整个流 <img src="/IT/it-bigdata-nifi-mysql-cdc/image-20220403161544824.png" alt="image-20220403161544824"></p>
</li>
<li><p>CaptureChangeMySQL</p>
<p><img src="/IT/it-bigdata-nifi-mysql-cdc/image-20220403113226934.png" alt="image-20220403113226934" style="zoom:50%;">   <img src="/IT/it-bigdata-nifi-mysql-cdc/image-20220403113606962.png" alt="image-20220403113606962" style="zoom:50%;"><img src="/IT/it-bigdata-nifi-mysql-cdc/image-20220403113827340.png" alt="image-20220403113827340" style="zoom:50%;"></p>
</li>
<li><p>RouteOnAttribute</p>
<p>根据SQL类型，新建了下面的4种类型 ，以及默认的unmatched类型，上图中设置了Include Begin/Commit Events将会路由到unmatched分支。<br><img src="/IT/it-bigdata-nifi-mysql-cdc/image-20220403161727165.png" alt="image-20220403161727165"></p>
</li>
</ul>
<h2 id="捕获的数据"><a href="#捕获的数据" class="headerlink" title="捕获的数据"></a>捕获的数据</h2><ul>
<li>SQL Statements</li>
</ul>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">use</span> tests;</span><br><span class="line"><span class="comment">-- 建议在cmd上执行</span></span><br><span class="line"><span class="keyword">drop</span> <span class="keyword">table</span> <span class="keyword">if</span> <span class="keyword">exists</span> tests.nifi_lab;</span><br><span class="line"><span class="keyword">create</span> <span class="keyword">table</span> <span class="keyword">if</span> <span class="keyword">not</span> <span class="keyword">exists</span> tests.nifi_lab ( <span class="keyword">id</span> <span class="built_in">int</span>, </span><br><span class="line">						<span class="keyword">name</span> <span class="built_in">varchar</span>(<span class="number">10</span>), </span><br><span class="line">						createtime <span class="built_in">timestamp</span> <span class="keyword">default</span> <span class="keyword">current_timestamp</span>  , </span><br><span class="line">						updatetime <span class="built_in">timestamp</span> <span class="keyword">DEFAULT</span> <span class="keyword">CURRENT_TIMESTAMP</span> <span class="keyword">ON</span> <span class="keyword">UPDATE</span>  <span class="keyword">current_timestamp</span></span><br><span class="line">					  );</span><br><span class="line"></span><br><span class="line"><span class="comment">-- 可以在数据库客户端执行，例如dbeaver。</span></span><br><span class="line"><span class="keyword">SELECT</span> <span class="keyword">id</span>, <span class="keyword">name</span>, createtime, updatetime</span><br><span class="line"><span class="keyword">FROM</span> tests.nifi_lab;</span><br><span class="line"></span><br><span class="line"><span class="keyword">insert</span> <span class="keyword">into</span> tests.nifi_lab (<span class="keyword">id</span>, <span class="keyword">name</span>) <span class="keyword">values</span> (<span class="number">1</span>, <span class="string">'Arthur'</span>);</span><br><span class="line"><span class="comment">-- name &amp; updatetime will be changed</span></span><br><span class="line"><span class="keyword">update</span> tests.nifi_lab <span class="keyword">set</span> <span class="keyword">name</span> = <span class="string">'Amy'</span> <span class="keyword">where</span> <span class="keyword">id</span> = <span class="number">1</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">delete</span> <span class="keyword">from</span> tests.nifi_lab <span class="keyword">where</span> <span class="keyword">id</span> = <span class="number">1</span>;</span><br></pre></td></tr></table></figure>



<ul>
<li><p>Include DDL Events: true</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    <span class="attr">"type"</span>: <span class="string">"ddl"</span>,</span><br><span class="line">    <span class="attr">"timestamp"</span>: <span class="number">1648912744000</span>,</span><br><span class="line">    <span class="attr">"binlog_filename"</span>: <span class="string">"binlog.000001"</span>,</span><br><span class="line">    <span class="attr">"binlog_position"</span>: <span class="number">1893</span>,</span><br><span class="line">    <span class="attr">"database"</span>: <span class="string">"tests"</span>,</span><br><span class="line">    <span class="attr">"table_name"</span>: <span class="literal">null</span>,</span><br><span class="line">    <span class="attr">"table_id"</span>: <span class="literal">null</span>,</span><br><span class="line">    <span class="attr">"query"</span>: <span class="string">"DROP TABLE IF EXISTS `nifi_lab` /* generated by server */"</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    <span class="attr">"type"</span>: <span class="string">"ddl"</span>,</span><br><span class="line">    <span class="attr">"timestamp"</span>: <span class="number">1648974582000</span>,</span><br><span class="line">    <span class="attr">"binlog_filename"</span>: <span class="string">"binlog.000001"</span>,</span><br><span class="line">    <span class="attr">"binlog_position"</span>: <span class="number">6045</span>,</span><br><span class="line">    <span class="attr">"database"</span>: <span class="string">"tests"</span>,</span><br><span class="line">    <span class="attr">"table_name"</span>: <span class="literal">null</span>,</span><br><span class="line">    <span class="attr">"table_id"</span>: <span class="literal">null</span>,</span><br><span class="line">    <span class="attr">"query"</span>: <span class="string">"create table tests.nifi_lab ( id int,  name varchar(10),  createtime timestamp default CURRENT_TIMESTAMP,  updatetime timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE  CURRENT_TIMESTAMP   )"</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



</li>
</ul>
<ul>
<li><p>Include Begin/Commit Event: true</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    <span class="attr">"type"</span>: <span class="string">"commit"</span>,</span><br><span class="line">    <span class="attr">"timestamp"</span>: <span class="number">1648912762000</span>,</span><br><span class="line">    <span class="attr">"binlog_filename"</span>: <span class="string">"binlog.000001"</span>,</span><br><span class="line">    <span class="attr">"binlog_position"</span>: <span class="number">2782</span>,</span><br><span class="line">    <span class="attr">"database"</span>: <span class="string">"tests"</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    <span class="attr">"type"</span>: <span class="string">"begin"</span>,</span><br><span class="line">    <span class="attr">"timestamp"</span>: <span class="number">1648973319000</span>,</span><br><span class="line">    <span class="attr">"binlog_filename"</span>: <span class="string">"binlog.000001"</span>,</span><br><span class="line">    <span class="attr">"binlog_position"</span>: <span class="number">4885</span>,</span><br><span class="line">    <span class="attr">"database"</span>: <span class="string">"tests"</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



</li>
</ul>
<ul>
<li><p>Insert</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    <span class="attr">"type"</span>: <span class="string">"insert"</span>,</span><br><span class="line">    <span class="attr">"timestamp"</span>: <span class="number">1648912762000</span>,</span><br><span class="line">    <span class="attr">"binlog_filename"</span>: <span class="string">"binlog.000001"</span>,</span><br><span class="line">    <span class="attr">"binlog_position"</span>: <span class="number">2727</span>,</span><br><span class="line">    <span class="attr">"database"</span>: <span class="string">"tests"</span>,</span><br><span class="line">    <span class="attr">"table_name"</span>: <span class="string">"nifi_lab"</span>,</span><br><span class="line">    <span class="attr">"table_id"</span>: <span class="number">103</span>,</span><br><span class="line">    <span class="attr">"columns"</span>:</span><br><span class="line">    [</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="attr">"id"</span>: <span class="number">1</span>,</span><br><span class="line">            <span class="attr">"name"</span>: <span class="string">"id"</span>,</span><br><span class="line">            <span class="attr">"column_type"</span>: <span class="number">4</span>,</span><br><span class="line">            <span class="attr">"value"</span>: <span class="number">1</span></span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="attr">"id"</span>: <span class="number">2</span>,</span><br><span class="line">            <span class="attr">"name"</span>: <span class="string">"name"</span>,</span><br><span class="line">            <span class="attr">"column_type"</span>: <span class="number">12</span>,</span><br><span class="line">            <span class="attr">"value"</span>: <span class="string">"Arthur"</span></span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="attr">"id"</span>: <span class="number">3</span>,</span><br><span class="line">            <span class="attr">"name"</span>: <span class="string">"createtime"</span>,</span><br><span class="line">            <span class="attr">"column_type"</span>: <span class="number">93</span>,</span><br><span class="line">            <span class="attr">"value"</span>: <span class="string">"2022-04-02 23:19:22.0"</span></span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="attr">"id"</span>: <span class="number">4</span>,</span><br><span class="line">            <span class="attr">"name"</span>: <span class="string">"updatetime"</span>,</span><br><span class="line">            <span class="attr">"column_type"</span>: <span class="number">93</span>,</span><br><span class="line">            <span class="attr">"value"</span>: <span class="string">"2022-04-02 23:19:22.0"</span></span><br><span class="line">        &#125;</span><br><span class="line">    ]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>update</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- name &amp; updatetime will be changed</span></span><br><span class="line"><span class="keyword">update</span> tests.nifi_lab <span class="keyword">set</span> <span class="keyword">name</span> = <span class="string">'Amy'</span> <span class="keyword">where</span> <span class="keyword">id</span> = <span class="number">1</span>;</span><br></pre></td></tr></table></figure>

<p>没有做修改的字段的值，依旧在update里。</p>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    <span class="attr">"type"</span>: <span class="string">"update"</span>,</span><br><span class="line">    <span class="attr">"timestamp"</span>: <span class="number">1648957879000</span>,</span><br><span class="line">    <span class="attr">"binlog_filename"</span>: <span class="string">"binlog.000002"</span>,</span><br><span class="line">    <span class="attr">"binlog_position"</span>: <span class="number">837</span>,</span><br><span class="line">    <span class="attr">"database"</span>: <span class="string">"tests"</span>,</span><br><span class="line">    <span class="attr">"table_name"</span>: <span class="string">"nifi_lab"</span>,</span><br><span class="line">    <span class="attr">"table_id"</span>: <span class="number">82</span>,</span><br><span class="line">    <span class="attr">"columns"</span>:</span><br><span class="line">    [</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="attr">"id"</span>: <span class="number">1</span>,</span><br><span class="line">            <span class="attr">"name"</span>: <span class="string">"id"</span>,</span><br><span class="line">            <span class="attr">"column_type"</span>: <span class="number">4</span>,</span><br><span class="line">            <span class="attr">"last_value"</span>: <span class="number">1</span>,</span><br><span class="line">            <span class="attr">"value"</span>: <span class="number">1</span></span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="attr">"id"</span>: <span class="number">2</span>,</span><br><span class="line">            <span class="attr">"name"</span>: <span class="string">"name"</span>,</span><br><span class="line">            <span class="attr">"column_type"</span>: <span class="number">12</span>,</span><br><span class="line">            <span class="attr">"last_value"</span>: <span class="string">"Arthur"</span>,</span><br><span class="line">            <span class="attr">"value"</span>: <span class="string">"Amy"</span></span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="attr">"id"</span>: <span class="number">3</span>,</span><br><span class="line">            <span class="attr">"name"</span>: <span class="string">"createtime"</span>,</span><br><span class="line">            <span class="attr">"column_type"</span>: <span class="number">93</span>,</span><br><span class="line">            <span class="attr">"last_value"</span>: <span class="string">"2022-04-02 23:19:22.0"</span>,</span><br><span class="line">            <span class="attr">"value"</span>: <span class="string">"2022-04-02 23:19:22.0"</span></span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="attr">"id"</span>: <span class="number">4</span>,</span><br><span class="line">            <span class="attr">"name"</span>: <span class="string">"updatetime"</span>,</span><br><span class="line">            <span class="attr">"column_type"</span>: <span class="number">93</span>,</span><br><span class="line">            <span class="attr">"last_value"</span>: <span class="string">"2022-04-02 23:19:22.0"</span>,</span><br><span class="line">            <span class="attr">"value"</span>: <span class="string">"2022-04-03 11:51:19.0"</span></span><br><span class="line">        &#125;</span><br><span class="line">    ]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
<li><p>delete</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">delete</span> <span class="keyword">from</span> tests.nifi_lab <span class="keyword">where</span> <span class="keyword">id</span> = <span class="number">1</span>;</span><br></pre></td></tr></table></figure>

<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    <span class="attr">"type"</span>: <span class="string">"delete"</span>,</span><br><span class="line">    <span class="attr">"timestamp"</span>: <span class="number">1648973324000</span>,</span><br><span class="line">    <span class="attr">"binlog_filename"</span>: <span class="string">"binlog.000001"</span>,</span><br><span class="line">    <span class="attr">"binlog_position"</span>: <span class="number">5671</span>,</span><br><span class="line">    <span class="attr">"database"</span>: <span class="string">"tests"</span>,</span><br><span class="line">    <span class="attr">"table_name"</span>: <span class="string">"nifi_lab"</span>,</span><br><span class="line">    <span class="attr">"table_id"</span>: <span class="number">104</span>,</span><br><span class="line">    <span class="attr">"columns"</span>:</span><br><span class="line">    [</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="attr">"id"</span>: <span class="number">1</span>,</span><br><span class="line">            <span class="attr">"name"</span>: <span class="string">"id"</span>,</span><br><span class="line">            <span class="attr">"column_type"</span>: <span class="number">4</span>,</span><br><span class="line">            <span class="attr">"value"</span>: <span class="number">1</span></span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="attr">"id"</span>: <span class="number">2</span>,</span><br><span class="line">            <span class="attr">"name"</span>: <span class="string">"name"</span>,</span><br><span class="line">            <span class="attr">"column_type"</span>: <span class="number">12</span>,</span><br><span class="line">            <span class="attr">"value"</span>: <span class="string">"Amy"</span></span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="attr">"id"</span>: <span class="number">3</span>,</span><br><span class="line">            <span class="attr">"name"</span>: <span class="string">"createtime"</span>,</span><br><span class="line">            <span class="attr">"column_type"</span>: <span class="number">93</span>,</span><br><span class="line">            <span class="attr">"value"</span>: <span class="string">"2022-04-03 16:08:39.0"</span></span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="attr">"id"</span>: <span class="number">4</span>,</span><br><span class="line">            <span class="attr">"name"</span>: <span class="string">"updatetime"</span>,</span><br><span class="line">            <span class="attr">"column_type"</span>: <span class="number">93</span>,</span><br><span class="line">            <span class="attr">"value"</span>: <span class="string">"2022-04-03 16:08:42.0"</span></span><br><span class="line">        &#125;</span><br><span class="line">    ]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<ul>
<li>没有设置<strong>Distributed Map Cache Client</strong>时</li>
</ul>
<figure class="highlight json"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">    <span class="attr">"type"</span>: <span class="string">"delete"</span>,</span><br><span class="line">    <span class="attr">"timestamp"</span>: <span class="number">1648960096000</span>,</span><br><span class="line">    <span class="attr">"binlog_filename"</span>: <span class="string">"binlog.000002"</span>,</span><br><span class="line">    <span class="attr">"binlog_position"</span>: <span class="number">2084</span>,</span><br><span class="line">    <span class="attr">"database"</span>: <span class="literal">null</span>,</span><br><span class="line">    <span class="attr">"table_name"</span>: <span class="literal">null</span>,</span><br><span class="line">    <span class="attr">"table_id"</span>: <span class="literal">null</span>,</span><br><span class="line">    <span class="attr">"columns"</span>:</span><br><span class="line">    [</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="attr">"id"</span>: <span class="number">1</span>,</span><br><span class="line">            <span class="attr">"value"</span>: <span class="number">1</span></span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="attr">"id"</span>: <span class="number">2</span>,</span><br><span class="line">            <span class="attr">"value"</span>: <span class="literal">null</span></span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="attr">"id"</span>: <span class="number">3</span>,</span><br><span class="line">            <span class="attr">"value"</span>: <span class="literal">null</span></span><br><span class="line">        &#125;,</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="attr">"id"</span>: <span class="number">4</span>,</span><br><span class="line">            <span class="attr">"value"</span>: <span class="literal">null</span></span><br><span class="line">        &#125;</span><br><span class="line">    ]</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>



</li>
</ul>
<h2 id="问题集"><a href="#问题集" class="headerlink" title="问题集"></a>问题集</h2><ul>
<li><p>如果没有配置<strong>Distributed Map Cache Client</strong>会提示warning</p>
<blockquote>
<p>可以忽略，不过输出结果没有字段名称和类型。所以建议设置。</p>
</blockquote>
</li>
<li><p>MySQL8账户密码类型不能使用默认的</p>
<blockquote>
<p>创建MySQL账户时需要指定mysql_native_password</p>
</blockquote>
</li>
</ul>

    </div>

    
    
    
        

  <div class="followme">
    <p>欢迎关注我的其它发布渠道</p>

    <div class="social-list">

        <div class="social-item">
          <a target="_blank" class="social-link" href="/atom.xml">
            <span class="icon">
              <i class="fa fa-rss"></i>
            </span>

            <span class="label">RSS</span>
          </a>
        </div>
    </div>
  </div>


      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/bigdata/" rel="tag"># bigdata</a>
              <a href="/tags/dataflow/" rel="tag"># dataflow</a>
              <a href="/tags/nifi/" rel="tag"># nifi</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/IT/it-bigdata-dataflow-nifi-cluster-installation/" rel="prev" title="Nifi集群安装">
      <i class="fa fa-chevron-left"></i> Nifi集群安装
    </a></div>
      <div class="post-nav-item">
    <a href="/IT/it-bigdata-flink-cdc-guava18-blink-conflicts/" rel="next" title="flink 1.14.4使用flink mysql cdc connector 2.2时报guava18、guava30和blink冲突问题">
      flink 1.14.4使用flink mysql cdc connector 2.2时报guava18、guava30和blink冲突问题 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#环境"><span class="nav-number">1.</span> <span class="nav-text">环境</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#检查MySQL-binlog开启情况"><span class="nav-number">2.</span> <span class="nav-text">检查MySQL binlog开启情况</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#创建MySQL用户和数据库"><span class="nav-number">3.</span> <span class="nav-text">创建MySQL用户和数据库</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#配置DistributedMapCacheServer-amp-Client"><span class="nav-number">4.</span> <span class="nav-text">配置DistributedMapCacheServer&amp;Client</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#创建和配置CaptureChangeMySQL"><span class="nav-number">5.</span> <span class="nav-text">创建和配置CaptureChangeMySQL</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#捕获的数据"><span class="nav-number">6.</span> <span class="nav-text">捕获的数据</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#问题集"><span class="nav-number">7.</span> <span class="nav-text">问题集</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="李联友"
      src="/images/header.jpg">
  <p class="site-author-name" itemprop="name">李联友</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">31</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">8</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">25</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/lianyouli" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;lianyouli" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">李联友</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://mist.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Mist</a> 强力驱动
  </div>

<script src="/js/jquery.min.js"> </script>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>



<script src="/js/code-unfold.js"></script>


  















  

  

</body>
</html>
